package com.kl.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kl.entity.TabOrder;
import com.kl.mapper.TabOrderMapper;
import com.kl.service.ITabOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2021-11-02
 */
@Service
public class TabOrderServiceImpl extends ServiceImpl<TabOrderMapper, TabOrder> implements ITabOrderService {

    @Autowired
    private TabOrderMapper tabOrderMapper;


    @Override
    public List<TabOrder> findAllOrderById(String id) {
        Map<String,Object>map = new HashMap<>();
        map.put("sign_receipt",id);

        List<TabOrder> tabOrders = tabOrderMapper.selectByMap(map);
        return tabOrders;
    }

    @Override
    public List<TabOrder> findOrderByPhoneAndId(Long id, String senderPhone) {
        QueryWrapper<TabOrder> queryWrapper = new QueryWrapper<>();

        queryWrapper.eq("id", id).or().eq("sender_phone",senderPhone);

        List<TabOrder> tabOrders = tabOrderMapper.selectList(queryWrapper);
        return tabOrders;
    }
}
